import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import BookView from '../views/BookView.vue'
import CartView from '../views/CartView.vue'
import UserView from '../views/User/UserView.vue'

Vue.use(VueRouter)

const routes = [
  {
    // 首页
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    // 图书页
    path: '/book',
    component: BookView,
  },
  {
    // 购物车
    path: '/cart',
    name: 'cart',
    component: CartView,
  },
  {
    // 支付
    path: '/pay',
    name: 'pay',
    props: true,
    component: () => import('../views/PayView.vue'),
  },
  {
    // 结算
    path: '/finish/:id',
    name: 'finish',
    props: true,
    component: () => import('../views/User/OrderView.vue'),
  },
  {
    // 我的
    path: '/user',
    name: 'user',
    component: UserView,
  },
  {
    // 注册
    path: '/regist',
    name: 'regist',
    component: () => import('@/views/User/RegistView.vue'),
  },
  {
    // 登录
    path: '/login',
    name: 'login',
    component: () => import('@/views/User/LoginView.vue'),
  },
  {
    // 个人空间
    path: '/space/:id',
    name: 'space',
    props: true,
    component: () => import('@/views/User/UserSpace.vue'),
  },
  {
    // 我的 => 我的提醒
    name: 'notification',
    path: '/user/notification',
    component: () => import('@/views/User/UserNotification.vue'),
  },
  {
    // 我的 => 短信息
    name: 'msg',
    path: '/user/msg',
    component: () => import('@/views/User/UserMsg.vue'),
  },
  {
    // 短信息 => 对话详情
    name: 'dialogue',
    path: '/dialogue/:id',
    props: true,
    component: () => import('@/views/User/MsgView.vue'),
  },
  {
    // 我的 => 拥有的书
    name: 'owebook',
    path: '/user/owebook',
    component: () => import('@/views/User/OweBook.vue'),
  },
  {
    // 我的 => 已购买的课程
    name: 'owecourse',
    path: '/user/owecourse',
    component: () => import('@/views/User/OweCourse.vue'),
  },
  {
    // 我的 => 我的订单
    name: 'order',
    path: '/user/order',
    component: () => import('@/views/User/UserOrder.vue'),
  },
  {
    // 我的 => 我的收藏
    name: 'fav',
    path: '/user/fav',
    component: () => import('@/views/User/UserFav.vue'),
  },
  {
    // 我的 => 我的关注
    name: 'follow',
    path: '/user/follow',
    component: () => import('@/views/User/UserFollow.vue'),
  },
  {
    // 图书详情
    path: '/book/:id',
    name: 'bookItem',
    props: true,
    component: () => import('../views/BookItemView.vue'),
  },
  {
    // 阅读详情
    path: '/read/:id',
    name: 'read',
    props: true,
    component: () => import('../views/ReadView.vue'),
  },
  {
    // 文章详情
    path: '/article/:id',
    name: 'articleItem',
    props: true,
    component: () => import('../views/ArticleView.vue'),
  },
  {
    // 图书-tag
    path: '/tag/:id',
    name: 'tag',
    props: true,
    component: () => import('../views/BookTagView.vue')
  },
  {
    // 更多训练营
    path: '/train',
    name: 'train',
    component: () => import('../views/TrainView.vue')
  },
  {
    // 训练营详情
    path: '/train/:id',
    name: 'trainItem',
    props: true,
    component: () => import('../views/TrainItem.vue')
  },
  {
    // 搜索-search
    path: '/search',
    // name: 'search',
    component: () => import('../views/SearchView.vue'),
    // 二级路由
    children: [
      {
        name: 'enter',
        path: '/',
        props: true,
        component: () => import('../views/SearchEnter.vue')
      },
      {
        name: 'result',
        path: 'result/:id',
        props: true,
        component: () => import('../views/SearchResult.vue'),
      }
    ]
  },
  {
    // 勘误页面
    name: 'error',
    path: '/error',
    props: true,
    component: () => import('../views/BookItemErr.vue')
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router
